package com.study.kt._01grammar._02oop

import java.awt.event.WindowEvent
import java.awt.event.WindowListener
import javax.swing.JButton
import javax.swing.JFrame

/**
 * <pre>
 *     author : xxs
 *     time   : 2021/01/05
 *     desc   : Java使用匿名内部类对比Kotlin
 * </pre>
 */
fun main() {
    val jFrame = JFrame("MyFrame")
    jFrame.addWindowListener(object : WindowListener {
        override fun windowOpened(e: WindowEvent?) {
        }

        override fun windowClosing(e: WindowEvent?) {
        }

        override fun windowClosed(e: WindowEvent?) {
        }

        override fun windowIconified(e: WindowEvent?) {
        }

        override fun windowDeiconified(e: WindowEvent?) {
        }

        override fun windowActivated(e: WindowEvent?) {
        }

        override fun windowDeactivated(e: WindowEvent?) {
        }
    })
    val jButton = JButton("MyButton")
    jButton.addActionListener {
        println(it)
    }
    jFrame.add(jButton)
    jFrame.pack()
    jFrame.isVisible = true
    jFrame.defaultCloseOperation = JFrame.EXIT_ON_CLOSE
}